package com.wdcloud.netlibrary.dispatcher;


import com.wdcloud.netlibrary.callback.DownloadFileCallback;
import com.wdcloud.netlibrary.callback.NetWorkCallback;
import com.wdcloud.netlibrary.util.OkHttpUtil;

import okhttp3.Request;

/**
 * 文件下载
 * <p>
 */

public class DownLoadDispatcher implements IDispatcher {

    public Request request;

    public String dir;

    public String fileName;

    private boolean isLocal = true;


    public DownLoadDispatcher(String dir, String fileName, Request request) {
        this.dir = dir;
        this.fileName = fileName;
        this.request = request;
    }

    public <T> void enqueue(NetWorkCallback<T> callback) {

    }

    @Override
    public <T> T execute(Class<T> c) throws Exception {
        return null;
    }

    @Override
    public <T> void execute(NetWorkCallback<T> callback) {

    }

    @Override
    public void downLoad(DownloadFileCallback callback) {
        OkHttpUtil.getInstance().downloadFile(this, callback);
    }

    @Override
    public void downLoadWithMemory(DownloadFileCallback callback) {
        OkHttpUtil.getInstance().downloadFileWithMemory(this, callback);
    }

    @Override
    public IDispatcher backOnMain(boolean flag) {
        isLocal = !flag;
        return this;
    }

    @Override
    public boolean isLocal() {
        return isLocal;
    }
}
